package com.gouwudai.gobbs.dao.impl;

import java.math.BigDecimal;
import java.util.List;

import org.apache.log4j.Logger;

import com.gouwudai.gobbs.dao.IRuleDAO;
import com.gouwudai.gobbs.pojo.TbbsRule;

public class RuleDAOImpl extends BaseDAOImpl implements IRuleDAO 
{
	private static final Logger logger = Logger.getLogger(RuleDAOImpl.class);	
	private static final String BUSI_NAME = "社区规则信息";
	
    /**
     * 更新社区规则
     * @param ruleId 规则ID
     * @param ruleMark 积分
     * @param ruleMoney 金币
     * @param ruleCredit 信誉
     * @param ruleDeposit 存款
     */
    public void update(Integer ruleId,BigDecimal ruleMark,BigDecimal ruleMoney,BigDecimal ruleCredit,BigDecimal ruleDeposit)
    {
        StringBuilder hql = new StringBuilder();
        hql.append("update TbbsRule set ruleMark=?");
        hql.append(", ruleMoney=?");
        hql.append(", ruleCredit=?");  
        hql.append(", ruleDeposit=?");
        hql.append(" where ruleId=?");
        super.updateObject(hql.toString(), new Object[]{
        	ruleMark,
        	ruleMoney,
        	ruleCredit,        	
        	ruleDeposit,
        	ruleId});
    }
    
    /**
     * 根据规则代码获得规则对象
     * @param ruleCode 规则代码
     * @return TbbsRule 规则对象
     */
    public TbbsRule loadByCode(String ruleCode)
    {
    	return (TbbsRule)super.loadObject(TbbsRule.class.getName(), "ruleCode",ruleCode);
    	
    }

    /**
     * 查询所有规则
     * @return List 所有规则列表
     */
    public List listAll()
    {       
    	return super.listAll("from TbbsRule where ruleCode<>'R016' AND ruleCode<>'R017'");
    }
    
}
